package apidocs;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import play.Play;
import play.vfs.VirtualFile;

/**
 * Created by zhangzc on 3/30/17.
 */
public class ApiUtils {

    public static JSONObject getApiJson(){
        VirtualFile jsonFile = Play.getVirtualFile("apidoc.json");
        JSONObject apiJson = null;
        if(jsonFile != null && jsonFile.exists()){
            String json = jsonFile.contentAsString();
            apiJson = JSON.parseObject(json);
        }else{
            apiJson = new JSONObject();
            apiJson.put("api_services", new JSONArray());
            apiJson.put("beans", new JSONObject());
        }
        return apiJson;
    }
}
